#!/usr/bin/env python3
"""
差异计数宇宙 v3.0
用法: python diff_count.py g dCdt gradC
"""
import numpy as np
import sys

# 读取耦合常数表（CSV 已加载为数组）
DATA = np.genfromtxt("gua_mapping_v3.csv", delimiter=",", skip_header=1)

def diff_count_z(g, dCdt, gradC):
    idx = int(g)
    if idx < 0 or idx > 63:
        raise ValueError("g must be 0-63")
    row = DATA[idx]
    _, _, _, chi, alpha, beta, gamma, kappa, _ = row
    z = alpha * dCdt + beta * gradC**2 + gamma * np.log(abs(chi) + 1e-6) + kappa * (chi - 0)
    return z

if __name__ == "__main__":
    g, dCdt, gradC = map(float, sys.argv[1:4])
    print(diff_count_z(g, dCdt, gradC))